
function RandChoice(list){
    var indx = Math.floor(Math.random() * list.length);
    return list[indx];
}


function AddBlast(e, color){
    for(var itr = 0; itr < 2; itr++){
        g_particleList.push(new Particle(e.x,e.y,-e.vx,-e.vy,color));
    }
}


var MaxParticleSize = 20;
function Particle(x,y, vx, vy, color){
    this.x = x;
    this.y = y;
    this.vx = vx+RandChoice([-2, -1, 1, 2]);  
    this.vy = vy+RandChoice([-2, -1, 1, 2]);
    this.col = color.split('(')[1].split(')')[0];
    this.alpha = 1.0;
    this.size = 5;
    this.live = true;

    this.update = function(){
        this.x = this.x + this.vx;
        this.y = this.y + this.vy;
        this.alpha -= 0.05;
        if(this.alpha < 0.1){
            this.alpha = 0.1;
        }
        this.size += 1;
        if(this.size > MaxParticleSize){
            this.live = false;
        }
    }

    this.draw = function(){
        ctx.fillStyle = "rgba(" + this.col + "," + this.alpha +")";
        ctx.fillRect(this.x, this.y, this.size, this.size);
    }
}   //end Particle class

